import 'package:json_annotation/json_annotation.dart';

@JsonSerializable()
class NovelKeyWordSearch extends Object {

  @JsonKey(name: 'books')
  List<Books> books;

  @JsonKey(name: 'total')
  int total;

  @JsonKey(name: 'ok')
  bool ok;

  NovelKeyWordSearch(this.books,this.total,this.ok,);

  factory NovelKeyWordSearch.fromJson(Map<String, dynamic> srcJson) => _$NovelKeyWordSearchFromJson(srcJson);

  Map<String, dynamic> toJson() => _$NovelKeyWordSearchToJson(this);

}


@JsonSerializable()
class Books extends Object {

  @JsonKey(name: '_id')
  String id;

  @JsonKey(name: 'hasCp')
  bool hasCp;

  @JsonKey(name: 'title')
  String title;

  @JsonKey(name: 'aliases')
  String aliases;

  @JsonKey(name: 'cat')
  String cat;

  @JsonKey(name: 'author')
  String author;

  @JsonKey(name: 'site')
  String site;

  @JsonKey(name: 'cover')
  String cover;

  @JsonKey(name: 'shortIntro')
  String shortIntro;

  @JsonKey(name: 'lastChapter')
  String lastChapter;

  @JsonKey(name: 'retentionRatio')
  double retentionRatio;

  @JsonKey(name: 'banned')
  int banned;

  @JsonKey(name: 'allowMonthly')
  bool allowMonthly;

  @JsonKey(name: 'latelyFollower')
  int latelyFollower;

  @JsonKey(name: 'wordCount')
  int wordCount;

  @JsonKey(name: 'contentType')
  String contentType;

  @JsonKey(name: 'superscript')
  String superscript;

  @JsonKey(name: 'sizetype')
  int sizetype;

  @JsonKey(name: 'highlight')
  Highlight highlight;

  Books(this.id,this.hasCp,this.title,this.aliases,this.cat,this.author,this.site,this.cover,this.shortIntro,this.lastChapter,this.retentionRatio,this.banned,this.allowMonthly,this.latelyFollower,this.wordCount,this.contentType,this.superscript,this.sizetype,this.highlight,);

  factory Books.fromJson(Map<String, dynamic> srcJson) => _$BooksFromJson(srcJson);

  Map<String, dynamic> toJson() => _$BooksToJson(this);

}


@JsonSerializable()
class Highlight extends Object {

  @JsonKey(name: 'title')
  List<String> title;

  Highlight(this.title,);

  factory Highlight.fromJson(Map<String, dynamic> srcJson) => _$HighlightFromJson(srcJson);

  Map<String, dynamic> toJson() => _$HighlightToJson(this);

}

NovelKeyWordSearch _$NovelKeyWordSearchFromJson(Map<String, dynamic> json) {
  return NovelKeyWordSearch(
    (json['books'] as List)
        ?.map(
            (e) => e == null ? null : Books.fromJson(e as Map<String, dynamic>))
        ?.toList(),
    json['total'] as int,
    json['ok'] as bool,
  );
}

Map<String, dynamic> _$NovelKeyWordSearchToJson(NovelKeyWordSearch instance) =>
    <String, dynamic>{
      'books': instance.books,
      'total': instance.total,
      'ok': instance.ok,
    };

Books _$BooksFromJson(Map<String, dynamic> json) {
  return Books(
    json['_id'] as String,
    json['hasCp'] as bool,
    json['title'] as String,
    json['aliases'] as String,
    json['cat'] as String,
    json['author'] as String,
    json['site'] as String,
    json['cover'] as String,
    json['shortIntro'] as String,
    json['lastChapter'] as String,
    (json['retentionRatio'] as num)?.toDouble(),
    json['banned'] as int,
    json['allowMonthly'] as bool,
    json['latelyFollower'] as int,
    json['wordCount'] as int,
    json['contentType'] as String,
    json['superscript'] as String,
    json['sizetype'] as int,
    json['highlight'] == null
        ? null
        : Highlight.fromJson(json['highlight'] as Map<String, dynamic>),
  );
}

Map<String, dynamic> _$BooksToJson(Books instance) => <String, dynamic>{
  '_id': instance.id,
  'hasCp': instance.hasCp,
  'title': instance.title,
  'aliases': instance.aliases,
  'cat': instance.cat,
  'author': instance.author,
  'site': instance.site,
  'cover': instance.cover,
  'shortIntro': instance.shortIntro,
  'lastChapter': instance.lastChapter,
  'retentionRatio': instance.retentionRatio,
  'banned': instance.banned,
  'allowMonthly': instance.allowMonthly,
  'latelyFollower': instance.latelyFollower,
  'wordCount': instance.wordCount,
  'contentType': instance.contentType,
  'superscript': instance.superscript,
  'sizetype': instance.sizetype,
  'highlight': instance.highlight,
};

Highlight _$HighlightFromJson(Map<String, dynamic> json) {
  return Highlight(
    (json['title'] as List)?.map((e) => e as String)?.toList(),
  );
}

Map<String, dynamic> _$HighlightToJson(Highlight instance) => <String, dynamic>{
  'title': instance.title,
};


